#ifndef _EDAPP_H_
#define _EDAPP_H_

#include "EDFrame.h"

#include "EDCamera.h"

#include "Timer.h"

#include "AnimationSystem.h"

// EDApp
//
// Main game/app class interface class.
// Contains the camera and other game objects.
class EDApp
{
	// Private constructor for singleton architecture
	EDApp(void){}
	// Private copy constructor for singleton architecture
	EDApp( const EDApp & ){}

	EDFrame m_CameraFrame;

	// Our skin
	Model m_Model;

	// Our bind pose
	Animation m_BindPose;

	// Some animation that we will pretend is being applied
	Animation m_SomeAnimation;

	// Interpolator that is generating our procedural animation for this example,
	// but would usually be doing practically the same thing as an articulated animation interpolator
	Interpolator m_Interpolator;

	// Where to store the new verts that will be rendered
	std::vector< vec3f > m_vSkinVerts;

	// Applies the rigid skinning algorithm
	// Uses the verts and transform indices from the mesh of m_Model, the bind pose from the keyframe transforms of m_BindPose,
	// the current key frame from m_Interpolator, and m_vSkinVerts to store the result.
	void ApplySmoothSkinning(void);

	matrix4f inverseBindPoseMatrix[2];
	unsigned int vertexNum;

	matrix4f MatrixInverse(matrix4f const* _mat);
	vec3f MatrixVectorMultiply(matrix4f const* _mat, vec3f const* _vec);

public: // members
	
	// The application's camera
	EDCamera m_Camera;

	// Frame timer
	Timer m_Timer;

public: // methods

	// Destructor
	~EDApp(void){}
	
	// GetInstance
	//
	// Gets the instance of the singleton
	//
	// Return:
	//		EDApp&	-	The singleton instance of the EDApp class
	static EDApp& GetInstance(void)
	{
		static EDApp theApp;
		return theApp;
	}
	// Initialize
	//
	// Initialize/Set-up the EDApp
	void Initialize(void);

	// Update
	//
	// Updates the camera and other game objects and renders the scene
	void Update(void);

	// Shutdown
	//
	// Shuts down the application and releases any remaining resources.
	void Shutdown(void);
};

#endif